package Day12;



/**
 * @Author kalista
 * @Description
 * @Date 2020/11/18  11:24
 **/

public class Person {


    private String name;
    private Integer age;


    public Person() {
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    // 解决异常 抛出
    public void setAge(Integer age) throws AgeException {
        if (age < 0){
            // 创造异常
            throw new AgeException("人的年龄不能为负数");
        }
        this.age = age;


    }

}
